<?php

namespace paper\http\middleware;

use paper\component\Middleware;
use paper\http\Request;
use paper\http\response\Response;

class Session extends Middleware
{

    function onBoot(Request $request, \Closure $next): Response
    {
        $session = new \paper\component\Session();
        $session->open();
        app()->session = $session;
        try {
            return $next();
        } finally {
            $session->close();
        }
    }
}